﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
using HZ.MBSM.BLL;
public partial class Manage_spellcompany : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)// 添加公司名拼音码
    {
        string name = "", strSql = "";


        int i = 0;
        Db db = new Db();
        System.Data.IDataReader dr;
        dr = db.DataReader("select  CompanyName,AccountId from company ");
        while (dr.Read())
        {
            name += dr["CompanyName"].ToString() + "┆" + dr["AccountId"] + "⊥";

        }
        dr.Close();
        dr.Dispose();

        for (i = 0; i < name.Split('⊥').Length -1; i++)
        {
            strSql = strSql + "@ update Company set QYPYM='" + PYM.GetChineseSpell(name.Split('⊥')[Int32.Parse(i.ToString())].Split('┆')[0]) + "' where AccountId=" + name.Split('⊥')[Int32.Parse(i.ToString())].Split('┆')[1];
        }
        if (strSql.Length > 0)
        {
            db.ExecuteTransaction(strSql.Substring(1).Split(new char[] { '@' }), 30);
        }
        db.Close();
        Response.Write("<script>alert('添加成功" + i + "条记录！');</script>");
    }
    protected void Button2_Click(object sender, EventArgs e)//添加商品通用名拼音码
    {
        string name = "", strSql = "";

       
       　int i = 0;
        Db db = new Db();
        System.Data.IDataReader dr;
        dr = db.DataReader("select ProductName,ProductId from Product  ");
        while (dr.Read())
        {
            name += dr["ProductName"].ToString() + "┆" + dr["ProductId"] + "⊥";

        }
        dr.Close();
        dr.Dispose();
        for (i = 0; i < name.Split('⊥').Length-1; i++)
        {
            strSql = "@ update Product set SpellingCode='" + PYM.GetChineseSpell(name.Split('⊥')[Int32.Parse(i.ToString())].Split('┆')[0]) + "' where ProductId=" + name.Split('⊥')[Int32.Parse(i.ToString())].Split('┆')[1];
            if (strSql.Length > 0)
            {
                db.ExecuteTransaction(strSql.Substring(1).Split(new char[] { '@' }), 30);
            }
        }
        
        db.Close();
        Response.Write("<script>alert('添加成功" + i + "条记录！');</script>");
    }
    /*protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        Response.Write("fdfdfdfdf");
        TreeView1.CollapseAll();
      TreeNode dd =  TreeView1.FindNode(TreeView1.LineImagesFolder);
     string tt= dd.Parent.Text;
    }*/
    protected void Button1_Click1(object sender, EventArgs e)
    {
        string name = "", strSql = "";


        int i = 0;
        Db db = new Db();
        System.Data.IDataReader dr;
        dr = db.DataReader("select ProductName,ProductId from Product  ");
        while (dr.Read())
        {
            name += dr["ProductName"].ToString() + "┆" + dr["ProductId"] + "⊥";

        }
        dr.Close();
        dr.Dispose();
        for (i = 0; i < name.Split('⊥').Length - 1; i++)
        {
            strSql = "@ update Product set SpellingCode='" + PYM.GetChineseSpell(name.Split('⊥')[Int32.Parse(i.ToString())].Split('┆')[0]) + "' where ProductId=" + name.Split('⊥')[Int32.Parse(i.ToString())].Split('┆')[1];
            if (strSql.Length > 0)
            {
                db.ExecuteTransaction(strSql.Substring(1).Split(new char[] { '@' }), 30);
            }
        }

        db.Close();
        Response.Write("<script>alert('添加成功" + i + "条记录！');</script>");

    }
}

 